﻿using Microsoft.Phone.Data.Linq.Mapping;
using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapHello.Data
{
    [Table]
    [Index(Columns = "Name")]
    public class Config : DataEntity
    {
        public const string WindowsLiveToken = "WindowsLiveToken";
        public const string WindowsLiveTokenExpired = "WindowsLiveTokenExpired";
        public const string IsLocationTracked = "IsLocationTracked";
        public const string MapCenter = "MapCenter";
        public const string ZoomLevel = "ZoomLevel";
        public const string MyNavigationPages = "MyNavigationPages";

        private string _id;
        [Column(IsPrimaryKey = true, DbType = "NVARCHAR(50) NOT NULL", CanBeNull = false)]
        public string Id
        {
            get
            {
                if (string.IsNullOrEmpty(this._id))
                {
                    _id = Guid.NewGuid().ToString();
                }
                return _id;
            }
            set
            {
                NotifyPropertyChanging("Id");
                _id = value;
                NotifyPropertyChanged("Id");
            }
        }

        private string _name;
        [Column(DbType = "NVARCHAR(50) NOT NULL")]
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                NotifyPropertyChanging("Name");
                _name = value;
                NotifyPropertyChanged("Name");
            }
        }

        private string _value;
        [Column(DbType = "NVARCHAR(1024) NOT NULL")]
        public string Value
        {
            get
            {
                return _value;
            }
            set
            {
                NotifyPropertyChanging("Value");
                _value = value;
                NotifyPropertyChanged("Value");
            }
        }

        private bool _isRoaming;
        [Column(DbType = "BIT NOT NULL")]
        public bool IsRoaming
        {
            get
            {
                return _isRoaming;
            }
            set
            {
                NotifyPropertyChanging("IsRoaming");
                _isRoaming = value;
                NotifyPropertyChanged("IsRoaming");
            }
        }
    }
}
